﻿#region 命名空间

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;
using WinnerCMS.BLL;
using WinnerCMS.Common;
using WinnerCMS.Model;
using WinnerCMS.Model.Attribute;

#endregion

namespace WinnerCMS.WebUI.Admin.ControlPanel
{
    [Access("265001,265009")]
    public partial class WinnerCMSSetting : WebFactory.PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    this.txtCMSDB.Text = WebConfig.ConnectionString;
                    this.txtSiteName.Text = WebConfig.SiteName;
                    this.txtWebSiteDomainName.Text = WebConfig.DomainName;


                    var config = CMSConfig.Instance();
                    this.txtUP.Text = config.UpLoadFolder;
                    this.txtWatherMakePath.Text = config.DrawingWater.DrawingWaterPath;
                    this.Ntxttransparent.Text = config.DrawingWater.Transparent.ToString();
                    this.Ntxtright.Text = config.DrawingWater.Right.ToString();
                    this.Ntxtbottom.Text = config.DrawingWater.Bottom.ToString();
                }
                catch (Exception ex)
                {
                    MsgBox.Message(ex.Message.Replace(@"\", @"\\"), this.UpdatePanel1);
                }
            }
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                WebConfig.SiteName = this.txtSiteName.Text;
                WebConfig.DomainName = this.txtWebSiteDomainName.Text.Trim();

                var config = CMSConfig.Instance();
                config.UpLoadFolder = this.txtUP.Text;
                config.DrawingWater.DrawingWaterPath = this.txtWatherMakePath.Text;
                config.DrawingWater.Transparent = Convert.ToInt32(this.Ntxttransparent.Text);
                config.DrawingWater.Right = Convert.ToInt32(this.Ntxtright.Text);
                config.DrawingWater.Bottom = Convert.ToInt32(this.Ntxtbottom.Text);


                config.Save(config);

                MsgBox.Message("保存成功!", this.UpdatePanel1);
            }
            catch (Exception Ex)
            {
                MsgBox.Message(Ex.Message.Replace(@"\", @"\\"), this.UpdatePanel1);
            }
        }
    }
}